<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE HTML>
<html>
<head>
<title>添加商品</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<style>
body{
	font-size:12px;
}
ul {
	border:1px solid black;
	list-style: none;
	padding: 0px;
	margin: 10px 0 0 0 ;
}
ul li{line-height:30px;}

#container{margin:auto;width:600px;}
</style>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery.min.js"></script>
</head>

<body>
	<div id="container">
		<form id="form1" action="<c:url value="/novel/testUpload" />" method="post" enctype="multipart/form-data"> <!-- enctype="multipart/form-data" --></form>
		<ul>
			<li>商品名称：<input form="form1" type="text" name="name" /></li>
			<li>商品价格：<input form="form1" type="number" name="price"  step="0.01"/></li>
			<li>商品图片：<input form="form1" type="file" name="file" /></li>
			<li>商品种类：
				<select form="form1" name="typeid">
					<option value="">--请选择--</option>
					<c:forEach items="${itemstypeList }" var="itemstype">
						<option value="${itemstype.id }">
							<c:if test="${itemstype.classid eq 1 || itemstype.classid eq 2}">
								&nbsp;&nbsp;--
							</c:if>
							${itemstype.name }
						</option>
					</c:forEach>
				</select>
			</li>
			<li>商品描述：<textarea form="form1"  name="detail"></textarea></li>
			
		</ul>
		<input id="addnext" type="button" value="下一个" />
		<input id="sub" type="button" value="发布" />
	</div>
	<script>
		$(function(){
			$("#addnext").click(function(){
				 var newtr = $("ul:first").clone()
				 newtr.insertAfter("ul:last");
				 newtr.find(":input").each(function(i){
			            $(this).val("");
			        });
				 
			});
			
			$("#sub").click(function(){
				/* $("ul").each(function(index){
				  	$(this).find("li:eq(0) input").attr("name","itemsList["+index+"].name");	
				  	$(this).find("li:eq(1) input").attr("name","itemsList["+index+"].price");	
				  	$(this).find("li:eq(2) input").attr("name","itemsList["+index+"].file");	
				  	$(this).find("li:eq(3) select").attr("name","itemsList["+index+"].typeid");	
				  	$(this).find("li:eq(4) textarea").attr("name","itemsList["+index+"].detail");	
				}); */
				
				$("#form1").submit();
			});
		});
	</script>
</body>
</html>